package own.stu.jobgib.playown.util.spel;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SpelTest {

    public static void main(String[] args) {
        SpelTest t = new SpelTest();
        t.test13_2();
    }

    public void test13_2() {
        Object user = new Object() {
            public Map<String, String> getInterests() {
                Map<String, String> interests = new HashMap<String, String>();
                interests.put("key1", "BasketBall");
                interests.put("key2", "FootBall");
                interests.put("key3", "Movie");
                return interests;
            }
        };
        ExpressionParser parser = new SpelExpressionParser();
        List<String> interests = (List<String>)parser.parseExpression("interests.![value]").getValue(user);
        for (String interest : interests) {
            System.out.println(interest.equals("BasketBall") || interest.equals("FootBall") || interest.equals("Movie"));
        }
    }

}
